#!/usr/bin/env node

const http = require('http'),
      url = require('url'),
      log  = console.log,
      addr = process.argv[2] || 'http://sample.wangding.co/web/one-div.html';

//url解析addr 结构是域名解析完了之后
let opt = url.parse(addr);
//log(opt)
//process.exit();
opt.headers = {'user-agent':'01-my-curl'};
                        
//传地址
http.get(addr, (res) => {
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  log(res.headers);
  log('');
                        
  res.pipe(process.stdout);
});
                       
